package
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.net.FileReference;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	
	import view.MessagePanel;
	import view.View;
	
	[SWF(width="770",height="550")]
	public class CutPhoto extends Sprite
	{
		private var _urlLoader:URLLoader;
		private var _view:View;
		private var _controller:MainController;
		public function CutPhoto()
		{
			
			_urlLoader=new URLLoader;
			_urlLoader.addEventListener(IOErrorEvent.IO_ERROR,onIO);
			_urlLoader.addEventListener(Event.COMPLETE,onComplete);
			_urlLoader.load(new URLRequest("CutPhotoConfig.xml"));
		}
		private function onIO(e:IOErrorEvent):void
		{
			init();
			
		}
		private function onComplete(e:Event):void
		{
			var xml:XML=new XML(e.target.data);
			CutPhotoConfig.min=xml.@min;
			CutPhotoConfig.max=xml.@max;
			CutPhotoConfig.scaleW=xml.@scaleW;
			CutPhotoConfig.scaleH=xml.@scaleH;
			CutPhotoConfig.serverUrl=xml.@serverUrl;
			init();
		}
		private function init():void
		{
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			MessagePanel.getInstance().setRoot(stage);
			_view=new View;
			addChild(_view);
			_controller=new MainController(_view);
		}
	}
}